import React, {Component} from "react";
import {Button, Form, Switch, Radio, DatePicker, Icon, Input, Select, Checkbox, Row, Col, message} from "antd";
const createForm = Form.create;
const FormItem = Form.Item;
const RadioGroup = Radio.Group;
const CheckboxGroup = Checkbox.Group;
const Option = Select.Option;
function noop() {
    return false;
}
class RoleForm extends Component {
    state = {
        option: '',
        loading: false,
        visible: true,
    }
    
    componentDidUpdate(nextProps, nextState) {
    }

    componentDidMount() {
    }

    render() {
        const {getFieldProps, getFieldError, isFieldValidating} = this.props.form;
        const formItemLayout = {
            labelCol: {span: 6},
            wrapperCol: {span: 18}
        };
        const option = this.props.init.option;
        this.state.data = this.props.init.data;

        let isDisabled = option == "view" ? true : false;

        return (
            <div >
                <Form horizontal>
                    <FormItem
                        label="角色名称："
                        labelCol={{span: 7}}
                        wrapperCol={{span: 12}}
                        hasFeedback>
                        <Input placeholder="请输入角色名称" disabled={(isDisabled )}
                               {...getFieldProps('rolename', {
                                   initialValue: this.state.data.rolename,
                                   rules: [
                                       {required: true, message: '请输入角色名称'}
                                   ]
                               })} />
                    </FormItem>
                    <FormItem
                        label="备注："
                        labelCol={{span: 7}}
                        wrapperCol={{span: 12}}>
                        <Input type="textarea" placeholder="请输入备注信息" id="textarea" disabled={isDisabled}
                               {...getFieldProps('described', {initialValue: this.state.data.described})}/>
                    </FormItem>
                    <Input type="hidden" {... getFieldProps('roleid', {initialValue: this.state.data.roleid})} />
                </Form>
            </div>
        );
    }
}
;
RoleForm = createForm()(RoleForm);
export default RoleForm
